﻿using DBUtil.FastEntity.Builders;
using DBUtil.FastEntity.Interface;
using System;
using System.Collections.Generic;
using System.Linq.Expressions;
using System.Text;

namespace DBUtil.FastEntity
{
    /// <summary>
    /// 实体操作工具实现
    /// </summary>
    /// <typeparam name="T"></typeparam>
    public class EntityUtil<T> : IEntityUtil<T> where T : class, new()
    {
        private readonly DBAccess db;

        public EntityUtil(DBAccess db)
        {
            this.db = db;
        }
        public DBAccess Db => db;

        #region 删除
        public long Delete(params int[] key)
        {
            throw new NotImplementedException();
        }

        public long Delete(params long[] key)
        {
            throw new NotImplementedException();
        }

        public long Delete(params string[] key)
        {
            throw new NotImplementedException();
        }

        public long Delete(Expression<Func<T, bool>> expressions)
        {
            throw new NotImplementedException();
        }
        #endregion

        #region 插入
        public int InsertAndGetId(T Model)
        {
            throw new NotImplementedException();
        }

        public long InsertAndGetIdLong(T Model)
        {
            throw new NotImplementedException();
        }

        public T InsertAndGetModel(T Model, Action<ISelectClause<T>> selectClause = null)
        {
            throw new NotImplementedException();
        }

        public List<T> InsertAndGetModels(List<T> Models, ISelectClause<T> selectClause = null)
        {
            throw new NotImplementedException();
        }

        public long InsertFromSelect(ISelectClause<T> fromSelectClause)
        {
            throw new NotImplementedException();
        }
        #endregion

        #region 查询
        public ISelectClause<T> Select()
        {
            return new SelectBuilder<T>(this);
        }

        public ISelectClause<T> Select(Expression<Func<T, bool>> whereExpression)
        {
            return Select().Where(whereExpression);
        }

        public ISelectClause<T> SelectByKey(params int[] key)
        {
            return Select().WhereKey(key);
        }

        public ISelectClause<T> SelectByKey(params long[] key)
        {
            return Select().WhereKey(key);
        }

        public ISelectClause<T> SelectByKey(params string[] key)
        {
            return Select().WhereKey(key);
        }
        #endregion

        #region 更新
        public long Update<TDto>(TDto dto) where TDto : class
        {
            throw new NotImplementedException();
        }

        public long Update<TDto>(TDto dto, Expression<Func<T, bool>> expression) where TDto : class
        {
            throw new NotImplementedException();
        }

        public long Update(T model)
        {
            throw new NotImplementedException();
        }

        public long UpdateBatch<TDto>(List<TDto> dtos) where TDto : class
        {
            throw new NotImplementedException();
        }

        public long UpdateBatch(List<T> models)
        {
            throw new NotImplementedException();
        }
        #endregion
    }
}
